package com.ruoyi.energize.service.impl;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.energize.domain.YancaoStoreDailySalesReport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.energize.mapper.CashOrderMapper;
import com.ruoyi.energize.domain.CashOrder;
import com.ruoyi.energize.service.ICashOrderService;

/**
 * energizeService业务层处理
 *
 * @author ruoyi
 * @date 2023-05-24
 */
@Service
public class CashOrderServiceImpl implements ICashOrderService
{
    @Autowired
    private CashOrderMapper cashOrderMapper;

    /**
     * 查询energize
     *
     * @param id energize主键
     * @return energize
     */
    @DataSource(DataSourceType.ZJPAY)
    @Override
    public CashOrder selectCashOrderById(Long id)
    {
        return cashOrderMapper.selectCashOrderById(id);
    }

    /**
     * 查询energize列表
     *
     * @param cashOrder energize
     * @return energize
     */
    @Override
    public List<CashOrder> selectCashOrderList(CashOrder cashOrder)
    {
        return cashOrderMapper.selectCashOrderList(cashOrder);
    }

    /**
     * 新增energize
     *
     * @param cashOrder energize
     * @return 结果
     */
    @Override
    public int insertCashOrder(CashOrder cashOrder)
    {
        return cashOrderMapper.insertCashOrder(cashOrder);
    }

    /**
     * 修改energize
     *
     * @param cashOrder energize
     * @return 结果
     */
    @Override
    public int updateCashOrder(CashOrder cashOrder)
    {
        cashOrder.setUpdateTime(DateUtils.getNowDate());
        return cashOrderMapper.updateCashOrder(cashOrder);
    }

    /**
     * 批量删除energize
     *
     * @param ids 需要删除的energize主键
     * @return 结果
     */
    @Override
    public int deleteCashOrderByIds(Long[] ids)
    {
        return cashOrderMapper.deleteCashOrderByIds(ids);
    }

    /**
     * 删除energize信息
     *
     * @param id energize主键
     * @return 结果
     */
    @Override
    public int deleteCashOrderById(Long id)
    {
        return cashOrderMapper.deleteCashOrderById(id);
    }

    @DataSource(DataSourceType.ZJPAY)
    @Override
    public List<YancaoStoreDailySalesReport> selectCashOrderListByDate(LocalDateTime dateTimeMin, LocalDateTime dateTimeMax){
        return cashOrderMapper.selectCashOrderListByDate(dateTimeMin,dateTimeMax);
    }

    /**
     * 通过OID连接字符串查询包含烟草的订单销售总金额
     * @param oidString
     * @return
     */
    @DataSource(DataSourceType.ZJPAY)
    @Override
    public BigDecimal selectCashOrderByOidStr(String oidString){
        //将字符串转化成数组集合
        List<String> oidStringList = Arrays.asList(oidString.split(","));
        return cashOrderMapper.selectCashOrderListByOidStr(oidStringList);
    }
}
